<?php
/**
 * Created by PhpStorm.
 * User: tommy
 * Date: 2018/6/15
 * Time: 10:31
 */

namespace frontend\service;
use common\models\info\Mood;
use backend\component\ResultFormat;
use backend\component\ResultEasyUIFormat;

class MoodService
{
    /****
     * 获取心情
     */
    public static function getMood(){
        $page = \Yii::$app->request->get("page",1);
        $pageSize = \Yii::$app->request->post("pageSize",15);
        $result = Mood::getMood($page,$pageSize);
        return $result;
    }
    public static function moodList($post) {
        $model = new Mood();
        $table = $model->dataListTable($post);
        return ResultEasyUIFormat::tableFormat($table)->asJson();
    }
    public static function auditMood($id,$post){
        $model = Mood::modelById($id);
        $model->status = $post['status'];
        if(!$model->save()){
            return ResultFormat::error($model->getErrorsToString());
        }
        return ResultFormat::success("审核成功");
    }
}
